package com.ding.easycontroller.utils;

import com.ding.easycontroller.work.*;

import javax.xml.crypto.Data;
import java.util.UUID;

//id生成策略
public class IdStrategy {

    public static String createId(Controller controller) {
      //  String p = "controller_" + controller.getUri() + "_SPACE_" + controller.getMethod();
       // return p.replace("/", "_BIAS_").replace("*", "_SPARK_").replace("{", "_PREBRACE_").replace("}", "_POSTBRACE_");


        return id();

    }

    public static String createId(WebSocket controller) {

    /*    String p = "websocket_" + controller.getUri();
        return p.replace("/", "_BIAS_").replace("*", "_SPARK_").replace("{", "_PREBRACE_").replace("}", "_POSTBRACE_");
    */
        return id();
    }

    public static String createId(Service service) {
        return service.getName();
    }

    public static String createId(Dao dao) {
        return dao.getName();
    }

    public static String createId(Filter filter) {
        return id();
    }

    private static String id() {
        return ("id_" + UUID.randomUUID().getLeastSignificantBits()).replace("-", "0");
    }

}
